<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <title>{{$shop->shop_name.'-'.$SEO['title']}}</title>
    <meta name="keywords" content="{{$SEO['keywords']}}"/>
    <meta name="description" content="{{$SEO['description']}}"/>
    <!--公用css引用-->
    @include('front.common.style')
            <!--END/公用css引用-->
    <link rel="stylesheet" href="../dist/css/index.css">
</head>
<body>
<!--公共头部-->
@include('front.common.header')

<!--END/公共头部-->
@inject('pictureService','App\Interfaces\PictureService')
@inject('userCollectionService','App\Interfaces\UserCollectionService')

<?php
function buildSearchLink($filter,$item){
    if(is_array($item)){
        foreach ($item as $k=>$v){
            $filter[$k] = $v;
        }
    }
    return http_build_query($filter);
}
$isInCollection=isset($user)?$userCollectionService->isInCollection($user->id,'SHOP',$shop->id):false;
?>

<!--店铺信息-->
<div class="inbox">
    <div class="shops-info">
        <div class="shop-params fn-rel">
            @if($isInCollection)
                <span class="fn-btn bg-success fav-btn">已收藏</span>
            @else
                <a href="javascript:;" data-id="{{$shop->id}}" data-type="SHOP" class="J-add-collection fn-btn btn-primary fav-btn text-btn"><i class="font-16">＋</i>收藏该店铺</a>
            @endif

            <div class="fn-ohide fn-mb16">
                <div class="fn-fl logo">
                    <a title="{{$shop->shop_name}}">
                        <img src="{{$pictureService::thumb($shop->shop_logo,180,72)}}" alt="{{$shop->shop_name}}">
                    </a>
                </div>

                <div class="name fn-mt14">
                    <h1 class="fn-dib-otw">{{$shop->shop_name}}</h1>
                    <div class="sub-name fn-mt4">在售商品<span class="text-color-1">{{$goodsPaginate->total()}}</span>个</div>
                </div>

            </div>
            <div class="info">
                <p class="des">{{$shop->shop_desc}}</p>
            </div>
        </div>
    </div>
</div>
<!--END/店铺信息-->



<div class="inbox">
    <div class="filter-wrap">
        {{--<!--分类-->--}}
        {{--<div class="key-link">--}}
            {{--<span class="label">分类：</span>--}}
            {{--<a href="#" class="link cur">洁面</a>--}}
            {{--<a href="#" class="link">保湿水</a>--}}
            {{--<a href="#" class="link">乳液</a>--}}
            {{--<a href="#" class="link">精华霜</a>--}}
            {{--<a href="#" class="link">防晒</a>--}}
            {{--<a href="#" class="link">彩妆</a>--}}
        {{--</div>--}}
        {{--<!--END/分类-->--}}

        <!--排序-->
        <div class="sort">
            <div class="page-num fn-fr"><span class="total-result">共搜索到<span class="text-color-1"> {{$goodsPaginate->total()}} </span>个结果</span><span class="text-color-2">{{$goodsPaginate->currentPage()}}</span>/{{$goodsPaginate->lastPage()}}</div>
            <span class="label">排序：</span>

            <span class="J-sort sort-param fn-dib @if ($filter['sort']=='') down @endif" url="/shop/{{$id}}?{{buildSearchLink($filter,['sort'=>''])}}">默认 <i class="icon"></i><i class="icon icon-arrow-t3"></i></span>
            <span class="J-sort sort-param fn-dib @if ($filter['sort']=='sale_desc') down @endif @if ($filter['sort']=='sale_asc') up @endif" url="/shop/{{$id}}?{{buildSearchLink($filter,['sort'=>($filter['sort']=='sale_asc')?'sale_desc':'sale_asc'])}}">销量  <i class="icon icon-arrow-b3"></i> <i class="icon icon-arrow-t3"></i></span>
            <span class="J-sort sort-param fn-dib @if ($filter['sort']=='price_desc') down @endif @if ($filter['sort']=='price_asc') up @endif" url="/shop/{{$id}}?{{buildSearchLink($filter,['sort'=>($filter['sort']=='price_asc')?'price_desc':'price_asc'])}}">价格 <i class="icon icon-arrow-b3"></i> <i class="icon icon-arrow-t3"></i></span>
            <label><input class="J-stock" type="checkbox" @if ($filter['stock']=='1') checked @endif  url="/shop/{{$id}}?{{buildSearchLink($filter,['stock'=>($filter['stock']==1)?0:1])}}">仅显示有货</label>
        </div>
        <!--END/排序-->

    </div>
</div>

@inject('goodsService','App\Interfaces\GoodsService')
@inject('pictureService','App\Interfaces\PictureService')
@inject('userCollectionService','App\Interfaces\UserCollectionService')

@if ($goodsPaginate->total()>0)
        <!--搜索结果-->
<div class="inbox result-list">
    <div class="panel-body">
        <ul class="imglist-2 ui-cols-4 imglist-2-ver imglist-skin-2">
            @foreach($goodsPaginate->getCollection() as $goods)
                <?php
                $deleted_at = $goods->deleted_at;
                $is_on_sale = $goods->is_on_sale;
                //$goods_number = $goods->goods_number;
                $goodsInCollection=isset($user)?$userCollectionService->isInCollection($user->id,'GOODS',$goods->goods_id):false;
                ?>
                @if(empty($deleted_at) && $is_on_sale==1)
                    <li class="col col-space">
                        <div class="col-box">
                            <div class="col-l">
                                <a href="/goods/{{$goods->goods_id}}" target="_blank" title="{{$goods->goods_name}}">
                                    <img class="lazy img-lazyload" data-src="{{$pictureService::thumb($goods->goods_thumb,254,254)}}" alt="{{$goods->goods_name}}">
                                </a>

                                @if($goods->goods_number==0)
                                    <i class="icon icon-soldout"></i>
                                @endif
                            </div>
                            <div class="col-r h-100">
                                <div class="panel-body">
                                    @if($goodsInCollection)
                                        <a href="javascript:;" class="fav-link fav"><i class="icon icon-fav"></i>已收藏</a>
                                    @else
                                        <a href="javascript:;" class="J-add-collection fav-link" reference_id="{{$goods->goods_id}}" collection-type="GOODS"><i class="icon icon-noFav"></i>收藏</a>
                                    @endif

                                    <p>
                                        <span class="text-color-1 font-14 fn-mr4">￥<span class="font-24">{{$goods->shop_price}}</span></span>
                                        @if($goods->shop_price>=60)
                                            <span class="bl-label label-brd-red fn-mb8">包邮</span>
                                        @endif
                                        <del class="fn-fr font-14 fn-mt6 fn-hide">￥{{$goods->market_price}}</del>
                                    </p>
                                    <a class="tit link fn-dib-otw ui-100" href="/goods/{{$goods->goods_id}}" target="_blank" title="{{$goods->goods_name}}">{{$goods->goods_name}}</a>
                                    <p class="sub-tit fn-dib-otw" title="{{$goods->goods_pet_name}}">{{$goods->goods_pet_name}}&nbsp;</p>

                                </div>
                            </div>
                        </div>
                    </li>
                @endif
            @endforeach
        </ul>
        <!--分页-->
        <div class="pager pager-big fn-tc">
            {!! $goodsPaginate->appends($filter)->render() !!}
        </div>

        <!--END/分页-->
    </div>

</div>
<!--END/搜索结果-->
@else

<!--无数据-->
<div class="inbox ui-brd-box1">
    <div class="bl-nodata nodata-imgtext nodata-imgtext-smaller">
        <div class="nodata-img">
            <img src="../images/mascot.png" alt="">
        </div>

        <div class="nodata-text nodata-con nodata-imgtext-small">
            <div class="h1">抱歉，没有找到相关的商品</div>
            <p>建议您：</p>
            <p>1、看看输入的文字是否有误</p>
            <p>2、拆分要搜索的关键词，分成几个词语再次搜索</p>
        </div>
    </div>
</div>
<!--END/无数据-->
@endif


<!--公共尾部-->
@include('front.common.footer')
        <!--END/公共尾部-->


<!--公用js引用-->
@include('front.common.script')
        <!--END/公用js引用-->

<script type="text/javascript">

    $('.sort-param').click(function(e){
        var item = $(e.currentTarget);
        var url = item.attr('url');
        window.location.href=url;
    });
    $('.J-stock').change(function(e){
        var item = $(e.currentTarget);
        var url = item.attr('url');
        window.location.href=url;
    });

</script>
</body>
</html>


